// 指向对象的指针： 把一个Time的对象设置为系统时间

#include <iostream>
#include <time.h>
using namespace std;

class Time {
private:
    int hour, min, sec;

public:
    Time();
    void Reset(int hour, int min, int sec);
    void ShowTime();
};

void SetTimeObject(Time* time);

int main() {
    Time t;
    cout << "几点了:\n";
    SetTimeObject(&t);
    t.ShowTime();
}

Time::Time() {
    hour = min = 0;
    sec = 1;
}

void Time::Reset(int hour, int min, int sec) {
    this->hour = hour;
    this->min = min;
    this->sec = sec;
}

void Time::ShowTime() {
    cout << "Time对象: " << hour << ":" << min << ":" << sec << "\n";
}

void SetTimeObject(Time* time) {
    time_t t;
    ::time(&t);
    tm* tm = localtime(&t);
    time->Reset(tm->tm_hour, tm->tm_min, tm->tm_sec);
}